package package1;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

@SuppressWarnings("unused")
public class FolderAndFileNamesToExcel {

	/**
	 * sorting out files for my taobao shop
	 * @param args
	 */
	public static void main(String[] args) {
//		Scanner s = new Scanner(System.in);
//		System.err.println("please input address");
//		String originalAddr = s.nextLine();
//		String qualifiedAddr = originalAddr.replaceAll("\\\\", "/");
//		System.err.println(qualifiedAddr);
		//E:\百度云\公众�??�和淘�?店\03淘�?店\塔罗�??务历�??�记�?
		//E:/百度�?/公众�??�和淘�?�?/03淘�?�?/塔罗�??务历�??�记�?
		String fileAddr = "E:/百度�?/公众�??�和淘�?�?/03淘�?�?/塔罗�??务历�??�记�?";
		File folder = new File(fileAddr);
		File[] files = folder.listFiles();
		String fullName;String date;String sequenceNo;String taobaoID;String fullSequenceNo;int number;
		HashMap<Integer,String> map = new HashMap<Integer,String>();
		for(File f:files){
			fullName = f.getName();
			if(!fullName.contains(" "))	continue;
			if(!fullName.contains("塔罗客户"))continue;
			File[] subFiles = f.listFiles();
			date = subFiles[0].getName().split(" ")[0]; 
			fullSequenceNo = fullName.split(" ")[0];
			sequenceNo = fullSequenceNo.substring(fullSequenceNo.indexOf("塔罗客户")+4);
			number = Integer.parseInt(sequenceNo);
			taobaoID = fullName.split(" ")[1];
			map.put(number, date+"\t" + taobaoID);
		}
		Set<Integer> set1 = map.keySet();
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.addAll(set1);
		Collections.sort(list);
		for(Integer a:list) System.err.println("塔罗客户"+a+"\t"+map.get(a));
	}
}
